"""
title/code => '用户基本资料/users'

=
++
---
~~~~
_____
^^^^^^
"""

RESOURCE_TEMPLATE = """\
.. _r-{{ code }}:

{{ title }}
{{ "="*(title | length)*2 }}

*TODO*


链接
++++

==== ======== ==== ====
关系 描述     方法 模版
---- -------- ---- ----
self 当前资源 GET  No
==== ======== ==== ====


属性
++++

**JSON** ::

 {
   "_links": {
     "self": {"href": "#self"}
   },
{% for column in columns %}\
{% if not loop.last %}\
   "{{ column[1] }}": "{{ column[2] }}",  # {{ column[0] }}
{% else %}\
   "{{ column[1] }}": "{{ column[2] }}"  # {{ column[0] }}
{% endif %}\
{% endfor %}\
 }\

{% for column in columns %}
* **{{ column[1] }}**\n
 {{ column[0] }}
{% endfor %}\

{% set extkey = '{}_ext_document'.format(code) %}\
{% if extkey in extensions %}\
{{ extensions[extkey][0] }}
{% endif %}\

#####

.. _r-{{ code }}-c:

{{ title }}集合
{{ "="*(title | length)*2 }}====

*TODO*


链接
++++

==== ======== ==== ====
关系 描述     方法 模版
---- -------- ---- ----
self 当前资源 GET  No
next 下一页   GET  No
prev 上一页   GET  No
==== ======== ==== ====


属性
++++

::

 {
   "_links": {
     "self": {"href": "#self"},
     "next": {"href": "#next"},
     "prev": {"href": "#prev"}
   },
   "_embedded": {
     "{{ code }}": [{
         "_links": {
           "self": {"href": "#self"}
         },
{% for column in columns %}\
{% if not loop.last %}\
         "{{ column[1] }}": "{{ column[2] }}",  # {{ column[0] }}
{% else %}\
         "{{ column[1] }}": "{{ column[2] }}"  # {{ column[0] }}
{% endif %}\
{% endfor %}\
       }, {
         "_links": {
           "self": {"href": "#self"}
         },
{% for column in columns %}\
{% if not loop.last %}\
         "{{ column[1] }}": "{{ column[2] }}",  # {{ column[0] }}
{% else %}\
         "{{ column[1] }}": "{{ column[2] }}"  # {{ column[0] }}
{% endif %}\
{% endfor %}\
       }]
   }
 }

{% set extkey = '{}_ext_collection'.format(code) %}\
{% if extkey in extensions %}\
{{ extensions[extkey][0] }}
{% endif %}\
"""

